package com.coolingme.register05.container02;

import java.lang.reflect.Constructor;

/**
 * 容器测试
 *
 * @author wangyue
 * @date 2020/9/29 16:06
 */
public class Test {

    public static void main(String[] args) {
        Object instance1 = ContainerSingleton.getInstance(Object.class);
        Object instance2 = ContainerSingleton.getInstance(Object.class);
        Object instance3 = ContainerSingleton.getInstance(Test.class);

        try {
            Class clazz = Integer.class;
            Constructor constructor = clazz.getConstructor(int.class);
            Object o = constructor.newInstance(1);
            System.out.println(o);
        } catch (Exception e) {
            e.printStackTrace();
        }

        System.out.println(instance1);
        System.out.println(instance2);
        System.out.println(instance3);
        System.out.println(instance1 == instance2);
        System.out.println(instance1 == instance3);

    }

}
